package br.com.linkers.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.Transaction;

import br.com.linkers.data.HibernateUtil;
import br.com.linkers.entity.Paises;

public class PaisDAO {
	Session session = HibernateUtil.getSessionFactory().openSession();
	Transaction transaction = session.beginTransaction();
	
	List<Paises> lista;
	
	public void newSession(){
		Session session = HibernateUtil.getSessionFactory().openSession();
		Transaction transaction = session.beginTransaction();
	}

	public Paises buscarPorId(Long id) {
		return (Paises) session.load(Paises.class, id);
	}
	
	public List<Paises> listar() {
		newSession();
		Criteria cri = session.createCriteria(Paises.class);
		this.lista = cri.list();
		return this.lista;
	}
	
	
}
